package com.zhuzi.controller;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.zhuzi.utils.HttpRequestUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.springframework.web.bind.annotation.*;

@Slf4j(topic = "ka")
@RestController
@RequestMapping("ka")
public class KaController {

    @PostMapping
    public String equ(@RequestBody String content) {
        log.info("equ-[{}]", content);

        JSONObject jsonObject = JSON.parseObject(content);
        for (String s : jsonObject.keySet()) {
            log.info("[{}]-[{}]", s, jsonObject.getString(s));
        }
        return "OK";
    }

    @GetMapping
    public String send() {

        String jsonStr = new JSONObject().fluentPut("dataType", "0x81").fluentPut("dataString", xmlContent).toJSONString();
        String sendUrl = "http://localhost:8080/goods/bus/api/gather.do";
        HttpRequestUtils.RespDTO respDTO = HttpRequestUtils.httpPostStatus(sendUrl, jsonStr, MapUtils.EMPTY_SORTED_MAP);
        log.info("接口发送-x82-得到的响应[{}]", respDTO);

        return "OK";

    }

    String xmlContent = "<GATHER_INFO><I_E_FLAG>I</I_E_FLAG><AREA_ID>480002</AREA_ID><CHNL_NO>i08</CHNL_NO><GETHER_MODE>A</GETHER_MODE><SESSION_ID>i0820220906161925</SESSION_ID><IC_INFO><IC_ID></IC_ID><IC_NO></IC_NO><IC_TYPE>D</IC_TYPE><IC_EXTENDED_CONTENT></IC_EXTENDED_CONTENT></IC_INFO><FORM_INFO><FORM_TYPE></FORM_TYPE><FORM_ID></FORM_ID></FORM_INFO><DR_CUSTOMS_NO></DR_CUSTOMS_NO><VE_CUSTOMS_NO></VE_CUSTOMS_NO><VE_LICENSE_NO>粤BB6380</VE_LICENSE_NO><CONTA_ID>OOLU7767542</CONTA_ID><CONTA_ID>OOLU7768521</CONTA_ID><ESEAL_ID></ESEAL_ID><GROSS_WT>39320</GROSS_WT><VE_RFID><RFID_ID></RFID_ID><VE_LICENSE_NO></VE_LICENSE_NO><VE_CUSTOMS_NO></VE_CUSTOMS_NO><VE_WT>0</VE_WT><VE_COMPANY></VE_COMPANY><VE_PERFORMANCE></VE_PERFORMANCE></VE_RFID><DR_RFID><RFID_ID></RFID_ID><DR_NAME></DR_NAME><DR_CUSTOMS_NO></DR_CUSTOMS_NO><DR_COMPANY></DR_COMPANY><DR_PERFORMANCE></DR_PERFORMANCE></DR_RFID><PHOTO><PHOTO_GUID></PHOTO_GUID><PHOTO_PERSPECTIVE></PHOTO_PERSPECTIVE></PHOTO><OPERATOR_ID></OPERATOR_ID><OPERATE_TIME></OPERATE_TIME><EXTEND><NAME></NAME><VALUE></VALUE></EXTEND><CONTA_RECOGNITION><CONTA_ID></CONTA_ID><CONTA_TYPE></CONTA_TYPE><CONTA_LOCK></CONTA_LOCK><CONFIDENCE_RATIO></CONFIDENCE_RATIO></CONTA_RECOGNITION><VE_LICENSE_RECOGNITION><DOMESTIC_LICENSE_NO>沪DB6380</DOMESTIC_LICENSE_NO><FOREIGN_LICENSE_COLOR>http://192.168.15.95:1987/S-T-A-R-T||DOWNFILE||20220906161931527.jpg||E-N-D</FOREIGN_LICENSE_COLOR><FOREIGN_LICENSE_NO></FOREIGN_LICENSE_NO><DOMESTIC_LICENSE_COLOR></DOMESTIC_LICENSE_COLOR><CONFIDENCE_RATIO></CONFIDENCE_RATIO></VE_LICENSE_RECOGNITION></GATHER_INFO>";

}
